package com.activiti.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.activiti.engine.FormService;
import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.FormType;
import org.activiti.engine.impl.form.FormPropertyHandler;
import org.activiti.engine.impl.form.FormPropertyImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 表单字段
 * @author: zyj
 * @create: 2020-01-16 13:43
 **/
public class MyFormProperty {


    protected String id;
    protected String name;
    protected FormType type;
    protected Map<String, Object> typeMap = new HashMap<>();
    protected boolean isRequired;
    protected boolean isReadable;
    protected boolean isWritable;

    protected String value;

    public MyFormProperty(FormProperty formPropertyHandler) {
        this.id = formPropertyHandler.getId();
        this.name = formPropertyHandler.getName();
        this.type = formPropertyHandler.getType();
        this.isRequired = formPropertyHandler.isRequired();
        this.isReadable = formPropertyHandler.isReadable();
        this.isWritable = formPropertyHandler.isWritable();
        typeMap.put("name",type.getName());
        typeMap.put("values", type.getInformation("values"));
        typeMap.put("datePattern",type.getInformation("datePattern"));
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public FormType getType() {
        return type;
    }

    public String getValue() {
        return value;
    }

    public boolean isRequired() {
        return isRequired;
    }

    public boolean isReadable() {
        return isReadable;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public boolean isWritable() {
        return isWritable;
    }

    public Map<String, Object> getTypeMap() {
        return typeMap;
    }

    public void setTypeMap(Map<String, Object> typeMap) {
        this.typeMap = typeMap;
    }
}
